<template>
<div>
<el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick"></el-tree>

  <baidu-map style="width:1400px;height:600px" class="map" :center="{lng: 116.404, lat: 39.915}" :zoom="15">
    <bm-navigation anchor="BMAP_ANCHOR_TOP_RIGHT"></bm-navigation>
    <bm-polygon strokeStyle='' anchor="BMAP_ANCHOR_TOP_RIGHT" :path="polygonPath" stroke-color="red" :stroke-opacity="0.5" :stroke-weight="2" :editing="true" @lineupdate="updatePolygonPath"/>
     <bm-polygon :path="polygonPath2" stroke-color="blue" :stroke-opacity="0.5" :stroke-weight="2" :editing="true" @lineupdate="updatePolygonPath2"/>

  </baidu-map>

  <el-button @click="cx">222</el-button>
</div>
</template>

<script>
export default {
  data () {
    return {
      polygonPath: [
        {lng: 116.412732, lat: 39.911707},
        {lng: 116.39455, lat: 39.910932},
        {lng: 116.403461, lat: 39.921336}

      ],
      polygonPath2: [
        {lng: 116.512732, lat: 39.811707},
        {lng: 116.49455, lat: 39.810932},
        {lng: 116.503461, lat: 39.821336}
      ],
       data: [{
          label: '一级 1',
          children: [{
            label: '二级 1-1',
            children: [{
              label: '三级 1-1-1'
            }]
          }]
        }, {
          label: '一级 2',
          children: [{
            label: '二级 2-1',
            children: [{
              label: '三级 2-1-1'
            }]
          }, {
            label: '二级 2-2',
            children: [{
              label: '三级 2-2-1'
            }]
          }]
        }, {
          label: '一级 3',
          children: [{
            label: '二级 3-1',
            children: [{
              label: '三级 3-1-1'
            }]
          }, {
            label: '二级 3-2',
            children: [{
              label: '三级 3-2-1'
            }]
          }]
        }],
        defaultProps: {
          children: 'children',
          label: 'label'
        }
    }
  },
  methods: {
    updatePolygonPath (e) {
      this.polygonPath = e.target.getPath()
    },
    addPolygonPoint () {
      this.polygonPath.push({lng: 116.404, lat: 39.915})
    },
    cx(){
      alert("1")
      console.log(this.polygonPath)
    },
      handleNodeClick(data) {
        alert(1)
        console.log(data);
      }
  }
}
</script>